<template>
	<div class="html_a">
	<van-nav-bar
	  class="header"	
	  left-arrow
	  @click-left="onClickLeft"
	>			
		<van-icon name="arrow-left" slot="left" color="#333"  size="20"/>
		<div slot="title" class="weight_header">通知消息</div>	
	</van-nav-bar>
	
    <div class="noData" v-if="showNoData">
    	<img src="../../../../static/img/lanhu/noData.png" alt="" />
    </div>	
	
	<van-pull-refresh v-model="refreshing" @refresh="onRefresh" :style="{ 'min-height': clientHeight + 'px' }" v-if="!showNoData">
	  <van-list
	    v-model="loading"
	    :finished="finished"
	    :finished-text="finishedText"
	    @load="onLoad"
	    :immediate-check="false"
	  >	  
	    <div class="wrap" v-for="(item,index) in list" :key="index" @click="goLink(item)">
		    <div class="b">
		    	<div class="c">
		    		<span class="c1">{{item.addtime}}</span>	    		
		    	</div>
		    	<div class="d">
		    		<div class="e">{{item.title}}</div>
		    		<div class="f" v-html="item.content"></div>
		    		<div class="g" v-if="item.nid==104">
		    			<div class="g1">查看详情</div>
		    			<div class="g2"><van-icon name="arrow" /></div>
		    		</div>
		    	</div>
		    </div>
		</div>	  
	  </van-list>
	</van-pull-refresh> 		
		       
	</div>	
</template>

<script>
import {getFun} from '@/api/publicFun.js'	 
let publicFun=getFun()	
export default {	
	data() {
       return {
       	  loading: false,    // 是否处于数据加载状态 
	      finished: false,   // 是否处于数据最底部的状态 
	      refreshing: false, // 是否处于下拉刷新状态         
          pageNum:1,         // 当前数据的页码数
          pages:0,           // 储存数据的最大页码数
          list:[],            // 储存数据用
          finishedText:'',
          showNoData:false,// 是否显示暂无数据
          url1:this.$api+'/marketorderservice/api/v1/market/selectInformationList'
       }
	},
	methods: {	
	   goLink(item){
	   	  if(item.nid==104){
	   	  	let arg='[{"refundId":"'+item.parameter+'"}]' 
	   	  	this.link('/market/intervention/result',arg)
	   	  }else{
	   	  	return false
	   	  }
	   },
	   // 下拉刷新函数	
	   onRefresh() {
		  setTimeout(() => {
	          this.pageNum=1
	          this.list=[]
	          this.getData()	
	          this.finished = false;
	          this.loading=false
			  this.refreshing = false;
		  }, 1000);          
	   },
	   // 上拉加载函数
	   onLoad(){	   	 
		 setTimeout(() => {		 	
	        if (this.refreshing) {
	          this.list = [];
	          this.refreshing = false;
	        }	        
	        this.pageNum++
	        if(this.pageNum>this.pages){this.finished = true;}
	        else{
              this.getData()
	          this.loading = false;	    
	          this.finishedText='我也是有底线的'
	        }
	      }, 1000);   	
	   },		
       // 获取数据
       getData(){
       	    let that=this
		    this.$Axios2.postRequest(this.url1,{userId:this.userId,noticeType:'1'},{pageNum:this.pageNum,pageSize:'5'})
		    .then(function(res) {
			  	if(res.data.page.total==0){
			  		that.showNoData=true
			  	}
		    	that.pages=res.data.page.pages
                that.list=that.list.concat(res.data.page.records)
                that.$nextTick(function(){
	                var img=document.getElementsByTagName('img')
	                for(var i=0;i<img.length;i++){
	                	img[i].style.width='100%'
	                }                	
                })
		    })       	
       }
	},
	mixins:[publicFun],	
	mounted() {
	    this.userId=this.$router.currentRoute.query.userId;
		this.getData()
		
	}
}	
</script>

<style scoped="" lang="scss">
.html_a{background: #f8f8f8;min-height: 100%;width: 100%;position: absolute;}	
.b{padding: 15px 10px 0;}
.c{text-align: center;margin-bottom: 15px;}
.c1{background: $common-color6;padding: 2px 6px;color: #fff;border-radius: 4px;}
.d{padding: 20px 15px 0px;background: #fff;border:1px solid #ededed;border-radius: 4px;}
.e{font-size: 16px;font-weight: bold;margin-bottom: 5px;}
.f{line-height: 20px;border-bottom:1px solid #ededed;padding-bottom: 10px;
   p{
   	img{width: 100px;}
   }
}
.g{padding: 10px 0;display: flex;align-items: center;justify-content: space-between;}
.g1{color:$common-color7;font-size: 14px;}
.g2{color: $common-color6;}
</style>


